package com.nwcl.ysx.service.impl;

import com.nwcl.common.utils.BeanUtil;
import com.nwcl.ysx.bo.RestaurantRoomBO;
import com.nwcl.ysx.dao.RestaurantRoomDao;
import com.nwcl.ysx.entity.RestaurantRoom;
import com.nwcl.ysx.service.RestaurantRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author liguiqin
 * @date 2023/5/26
 */
@Service
public class RestaurantRoomServiceImpl implements RestaurantRoomService {
    @Autowired
    private RestaurantRoomDao restaurantRoomDao;
    @Override
    public List<RestaurantRoomBO> listByRestaurantId(Integer restaurantId) {
        List<RestaurantRoom> list =restaurantRoomDao.listByRestaurantId(restaurantId);
        if(CollectionUtils.isEmpty(list)){
            return Collections.emptyList();
        }
        return BeanUtil.copyList(list,RestaurantRoomBO.class);
    }

    @Override
    public RestaurantRoomBO getById(Integer id) {
        RestaurantRoom model =  restaurantRoomDao.getById(id);
        if(model==null){
            return null;
        }
        return BeanUtil.copy(model,RestaurantRoomBO.class);
    }
}
